
<?php

//session_register(id_resep);


$query_resep=dbQuery("select * from tbresep where id_resep='$_GET[id_resep]'");
$data4=dbArray($query_resep);
$idresep=$data4['id_resep'];
$_SESSION['id_resep']=$idresep;
$resep=$_SESSION['id_resep'];
	//Pagging	
	$batas_data				=	20;
	$page					=	$_GET["page"];
	if(empty($page)) {
		$posisi				=	0;
		$page				=	1;
	} else {
		$posisi				=	($page - 1) * $batas_data;
	}
//Select Data
	$query=dbQuery("select * from tbobat a,tbjenis b where a.id_jenis=b.id_jenis order by a.nama_obat limit $posisi,$batas_data")or die(mysql_error());
	
	
	
	echo"<tr><td colspan='3'>&nbsp;</td></tr>";
	echo"<tr><td colspan='3' class='judul'>&#187 Management Obat</td></tr>";
	echo"<tr><td colspan='3' class='jarak_garis'><hr color='#6d6a69'>&nbsp;</hr></td></tr>";

	?>
	<?php
	$query_cus=dbQuery("select * from tbcustomer where id_customer='$_GET[id_customer]'");
	$data_cus=dbArray($query_cus);
	$idcus=$data_cus['id_customer']
	?>
	<table width="100%" border="0" cellpadding="3" cellspacing="1" align="center" class="tabel">
		<tr> 
    		
  		</tr>
		<form name="search_obat" id="search_obat" action="index_pegawai.php?index=search_obat&cryption=<?php print $encode."*upn*".$santra.$random; ?>
         &id_customer=<?php $idcus ?>" method="post">
		 <?echo"<script>alert('id customer $idcus')</script>";?>
		<tr bgcolor="#1085ac">
    	<td  colspan="9" height="20" ><span class="title_atas">Search Obat</span> 
		<input type="text" size="20" name="key" id="key" class="form"/>&nbsp;
			
			 
				<select name="field" id="field" class="form">
				<option value="0" class="form" >-- Option--</option>
				
				 <option class="form" value="nama_obat"> Nama Obat</option>
				 <option class="form" value="nama_jenis"> Kategori </option>
				 				
			</select>
			<input type="image" name="cari" id="cari" src="../picture/search.png" width="15" height="15"  onclick="return cari_order();" /></td>
			
			
			<td height="20" colspan="2"> <a href="input_admin.php?index=input_obat&cryption=<?=$random."santra".$upn.$encode?>"><img src="../picture/add_page.png" width="20" height="20" border="0"></a>
			</td>
		  	</tr>
	<tr class="title_atas" bgcolor="#0ab3eb" align="center">
		<td width="20%" align="center">ID Obat</td>
		<td width="20%">Nama Obat</td>
		<td width="10%">Jenis</td>
		
		<td width="15%">Harga</td>
		<td width="5%">Stok</td>
		<td width="2%">Bentuk</td>
		
		<td width="2%" colspan="2" >Action</td>
		
	</tr>
	<?php
	
		$urutan = 1;
	while($data=dbAssoc($query)){
		if($urutan% 2 == 0) {
				$bgcolor	=	"#5ad1f4";
			} else {
				$bgcolor	=	"#FFFFFF";
	}
	$harga=$data[harga_jual];
	$harga_tampil=Uang($harga);
	
	?>
	
	<tr class="list_admin" align="center" bgcolor="<?=$bgcolor?>">
	<td width="20%" align="center" ><?=$data[id_obat]?></td>
		<td width="20%" align="center" ><?=$data[nama_obat]?></td>
		<td width="20%" align="center"><?=$data[nama_jenis]?></td>
		<td width="10%" align="center"><?=$harga_tampil;?></td>
		<td width="10%" align="center"><?=$data[stok]?></td>
		<td width="15%" align="center"><?=$data[bentuk]?></td>
		
				
	
    		
			
			<td><a href="<?php echo "index_pegawai.php?index=form_add_obat&id=$data[id_obat]&id_resep=$resep&id_customer=$idcus&cryption=$encode.*upn*.$santra.$random"; ?>"> <img src="../picture/open.png" width="15" height="15" border="0" /></a></td>
			<td><a href="<?php echo "index_pegawai.php?index=detail_obat&id=$data[id_obat]&id_resep=$resep&id_customer=$idcus&cryption=$encode.*upn*.$santra.$random"; ?>"> <img src="../picture/detail.png" width="15" height="15" border="0" /></a></td>
	</tr>
	
	
	<?$urutan ++;
}
	
	?>
	
	
	
	
	
	<?php
	
	
	echo "<tr><td colspan='9'>&nbsp;</td></tr>";
	echo "<tr><td colspan='9'><div align='center' id='pagging'>";
	$sql	=	"select * from tbobat a,tbjenis b where a.id_jenis=b.id_jenis order by a.nama_obat   ";
	$query3	=	dbQuery($sql);

	$baris	=	dbRows($query3);
	$jumlahhalaman			=	ceil($baris/$batas_data);
	$file_place				=	"index_pegawai.php?index=manage_product&cryption=$encode.*phb*.$phb.$random";
	if ($page > 1) {
		$previous			=	$page - 1;
		echo "<a href='$file_place&page=1'><< First</a> | <a href='$file_place&page=$previous'>< Previous</a> | ";
	} else {
		echo "<< First | < Previous | ";
	}
	for($ifa=1; $ifa<=$jumlahhalaman; $ifa++) {
		if($ifa != $page) {
			echo " <a href='$file_place&page=$ifa'>$ifa</a> | ";
		} else {
			echo " <strong>$ifa</strong> | ";
		}
	}
	if($page < $jumlahhalaman) {
		$next				=	$page + 1;
		echo "<a href='$file_place&page=$next'>Next ></a> | <a href='$file_place&page=$jumlahhalaman'>Last >></a>";
	} else {
		echo "Next > | Last >>";
	}
	echo"<tr><td colspan='2'>&nbsp</tr>";
	echo"</table></td></tr>";
	
	
	

		
?>